# Maintainer: Biswapriyo Nath <nathbappai@gmail.com>

_realname=zix
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=0.6.2
pkgrel=1
pkgdesc="A lightweight C99 portability and data structure library (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'archlinux: zix'
)
url='https://gitlab.com/drobilla/zix/'
license=('spdx:0BSD OR ISC')
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-cc"
  "${MINGW_PACKAGE_PREFIX}-glib2"
  "${MINGW_PACKAGE_PREFIX}-meson"
  "${MINGW_PACKAGE_PREFIX}-ninja"
  "${MINGW_PACKAGE_PREFIX}-pkgconf"
  "${MINGW_PACKAGE_PREFIX}-winpthreads"
)
source=("https://download.drobilla.net/${_realname}-${pkgver}.tar.xz"{,.sig})
sha256sums=('4bc771abf4fcf399ea969a1da6b375f0117784f8fd0e2db356a859f635f616a7'
            'SKIP')
validpgpkeys=('907D226E7E13FA337F014A083672782A9BF368F3') # David Robillard <d@drobilla.net>

build() {
  LDFLAGS+=" -pthread" \
  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/meson.exe setup \
      --prefix="${MINGW_PREFIX}" \
      --wrap-mode=nodownload \
      --auto-features=enabled \
      --buildtype=plain \
      -Ddocs=disabled \
      "build-${MSYSTEM}" \
      "${_realname}-${pkgver}"

  ${MINGW_PREFIX}/bin/meson.exe compile -C "build-${MSYSTEM}"
}

check() {
  ${MINGW_PREFIX}/bin/meson.exe test -C "build-${MSYSTEM}" || warning "Tests failed"
}

package() {
  ${MINGW_PREFIX}/bin/meson.exe install -C "build-${MSYSTEM}" --destdir "${pkgdir}"
  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
